<script src="{{ getAssets }}lodop/LodopFuncs.js?v={{ assets_version }}"></script>
<script>
	$(document).on("click","*[ectype='btnPrint']",function() {
		var printer = printType.defaults;
		var width = $("input[name='width']").val();
		var height = $("input[name='height']").val();
		 
		if (printer == '' || printer == null) {
			alert("该打印规格还没有设置指定的打印机");
			return false;
		}
		var html = $("#printContent").html();
		var title = "{{.title}}";
		
		PrintMytable(title, html, printer,width,height);
	});
	
	$(document).on("click","*[ectype='btnPreview']",function() {
		var printer = printType.defaults;
		var width = $("input[name='width']").val();
		var height = $("input[name='height']").val();
		 
		if (printer == '' || printer == null) {
			alert("该打印规格还没有设置指定的打印机");
			return false;
		}

		var html = $("#order-table").html();
		var title = "{{.title}}";
		PreviewMytable(title, html, printer,width,height);
	});
	
	function PreviewMytable(title, html, printer, width, height){
		var LODOP=getLodop();  
		LODOP.PRINT_INIT(title);
		
		//打印纸张尺寸
		width = width + 'mm';
		
		if(height == ""){
			height = "100%"
		}else{
			height = height + 'mm'
		}
		LODOP.SET_PRINT_PAGESIZE(1,width,height,'CreateCustomPage');
		
		LODOP.ADD_PRINT_TABLE(10,0,'100%','100%',$('#order-table').html());
		
		LODOP.PREVIEW();	
	}	
	
	function PrintMytable(title, html, printer, width, height){
		var LODOP=getLodop();  
		LODOP.PRINT_INIT(title);
		
		//打印纸张尺寸
		width = width + 'mm';
		
		if(height == ""){
			height = "100%"
		}else{
			height = height + 'mm'
		}
		LODOP.SET_PRINT_PAGESIZE(1,width,height,'CreateCustomPage');
		
		LODOP.ADD_PRINT_TABLE(10,0,'100%','100%',$('#order-table').html());
		
		LODOP.PRINT();	
	};	
	
	$('.indexs').each(function(index, element) {
        $(this).html(index+1);
    });
</script>